﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;

namespace WPF测试
{
    public class MainWindowViewModel: BindableBase
    {
		private string _time;

		public string Time
		{
			get { return _time; }
			set { _time = value; RaisePropertyChanged(); }
		}

        public MainWindowViewModel()
        {
            Time = DateTime.Now.ToString();
            //设置优先级，防止跳秒
            DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Normal);
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += (s, e) => Time = DateTime.Now.ToString();
            timer.Start();
        }
    }
}
